const router = require('express').Router()
const multer = require('multer')

const fileController = require('../controller/fileController')

const storage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, 'public/upload')
    },
    filename: function (req, file, cb) {
        console.log(file);
        cb(null, file.originalname)
    }
})

const upload = multer({ storage:storage })

// 文件上传
router.post('/', upload.single('file'), fileController.upload)

module.exports = router